package com.pfzy.ui

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import com.pfzy.ui.activity.*
import com.pfzy.ui.activity.dragsort.DragSortActivity
import com.pfzy.ui.activity.floatview.FloatActivity
import com.pfzy.ui.activity.fragmentationx.FragmentationxActivity
import com.pfzy.ui.activity.local.localActivity
import com.pfzy.ui.activity.nest_recycler.NestRecyclerViewActivity
import com.pfzy.ui.activity.nest_recycler.NestRecyclerViewActivity2
import com.pfzy.ui.activity.nested.NestedScrollActivity
import com.pfzy.ui.activity.notification.NotificationActivity
import com.pfzy.ui.activity.pick.PickerActivity
import com.pfzy.ui.activity.refresh.RefreshActivity
import com.pfzy.ui.activity.refresh.refresh2.RefreshXActivity
import com.pfzy.ui.activity.refresh.refresh3.RefreshSmartActivity
import com.pfzy.ui.activity.shadow.ShadowActivity
import com.pfzy.ui.activity.stroke.StrokerTextActivity
import com.pfzy.ui.activity.tabtool.TabToolActivity
import com.pfzy.ui.activity.voice.VoiceActivity
import com.pfzy.ui.databinding.ActivityMainBinding
import java.util.*

class MainActivity : AppCompatActivity() {
    private lateinit var mBind: ActivityMainBinding
    private var mAdapter: ActivityAdapter? = null
    private val mDemoList: MutableList<DemoDetails> = ArrayList<DemoDetails>()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mBind = ActivityMainBinding.inflate(layoutInflater)
        setContentView(mBind.root)
        initView()
    }

    private fun initView() {
        initDemoList()

        mBind.mainList.layoutManager = LinearLayoutManager(this)
        mAdapter = ActivityAdapter(mDemoList)
        mBind.mainList.adapter = mAdapter
        mAdapter!!.setOnItemClickListener { adapter, view, position ->
            val demo: DemoDetails = adapter.getItem(position) as DemoDetails
            if (demo.activityClass != null) {
                val intent = Intent()
                intent.setClass(this@MainActivity, demo.activityClass)
                startActivity(intent)
            }
        }
    }

    private fun initDemoList(){
        mDemoList.add(DemoDetails("刷新3", RefreshSmartActivity::class.java))
        mDemoList.add(DemoDetails("刷新2", RefreshXActivity::class.java))
        mDemoList.add(DemoDetails("刷新", RefreshActivity::class.java))
        mDemoList.add(DemoDetails("tab滑动", FragmentationxActivity::class.java))
        mDemoList.add(DemoDetails("单选组", RadioGroupActivity::class.java))
        mDemoList.add(DemoDetails("录音", VoiceActivity::class.java))
        mDemoList.add(DemoDetails("页面切换", ViewChangeActivity::class.java))
        mDemoList.add(DemoDetails("滚动图", BannerActivity::class.java))
        mDemoList.add(DemoDetails("开关", SwitchActivity::class.java))
        mDemoList.add(DemoDetails("吐司", ToastActivity::class.java))
        mDemoList.add(DemoDetails("浮窗", FloatActivity::class.java))
        mDemoList.add(DemoDetails("通知栏", NotificationActivity::class.java))
        mDemoList.add(DemoDetails("滚动控件吸顶2", NestRecyclerViewActivity2::class.java))
        mDemoList.add(DemoDetails("滚动控件吸顶1", NestRecyclerViewActivity::class.java))
        mDemoList.add(DemoDetails("滚动控件吸顶", NestedScrollActivity::class.java))
        mDemoList.add(DemoDetails("阴影样式", ShadowActivity::class.java))
        mDemoList.add(DemoDetails("字体样式", StrokerTextActivity::class.java))
        mDemoList.add(DemoDetails("时钟选择", PickerActivity::class.java))
        mDemoList.add(DemoDetails("拖拽换位", DragSortActivity::class.java))
        mDemoList.add(DemoDetails("进度条", SeekBarActivity::class.java))
        mDemoList.add(DemoDetails("原生定位", localActivity::class.java))
        mDemoList.add(DemoDetails("tab标签", TabToolActivity::class.java))
    }
}